<?php

namespace app\controller;

use app\BaseController;
use app\fe\amis\Crud;
use think\helper\Str;

class UIDataController extends BaseController
{
    public function table($modelName)
    {
        $modelClass = '\\app\\model\\' . ucfirst($modelName);

        $model = new $modelClass(); /** @var \think\Model $model */

        // TODO 实现按条件查询及分页
        $rows = $model->select();

        $totalCount = 2104;

        return $this->dataToJson($rows, $totalCount);
    }

    protected function dataToJson($rows, $totalCount)
    {
        return $this->toJson(0, [
            'items' => $rows,
            'total' => $totalCount,
        ]);
    }
}